import 'package:json2dart_safe/json2dart.dart';

class MineMessageModel {
  int? consumerUserId;
  String? content;
  String? createdAt;
  int? informationType;
  String? msgActionDesc;
  int? producerIdentity;
  String? producerLogo;
  String? producerName;
  int? producerUserId;
  QuoteMsg? quoteMsg;
  String? updatedAt;

  MineMessageModel({
    this.consumerUserId,
    this.content,
    this.createdAt,
    this.informationType,
    this.msgActionDesc,
    this.producerIdentity,
    this.producerLogo,
    this.producerName,
    this.producerUserId,
    this.quoteMsg,
    this.updatedAt,
  });

  Map<dynamic, dynamic> toJson() {
    return <dynamic, dynamic>{}
      ..put('consumerUserId', consumerUserId)
      ..put('content', content)
      ..put('createdAt', createdAt)
      ..put('informationType', informationType)
      ..put('msgActionDesc', msgActionDesc)
      ..put('producerIdentity', producerIdentity)
      ..put('producerLogo', producerLogo)
      ..put('producerName', producerName)
      ..put('producerUserId', producerUserId)
      ..put('quoteMsg', quoteMsg?.toJson())
      ..put('updatedAt', updatedAt);
  }

  MineMessageModel.fromJson(Map<dynamic, dynamic> json) {
    consumerUserId = json.asInt('consumerUserId');
    content = json.asString('content');
    createdAt = json.asString('createdAt');
    informationType = json.asInt('informationType');
    msgActionDesc = json.asString('msgActionDesc');
    producerIdentity = json.asInt('producerIdentity');
    producerLogo = json.asString('producerLogo');
    producerName = json.asString('producerName');
    producerUserId = json.asInt('producerUserId');
    quoteMsg = json.asBean('quoteMsg', (v) => QuoteMsg.fromJson(v));
    updatedAt = json.asString('updatedAt');
  }

  static MineMessageModel toBean(Map<String, dynamic> json) =>
      MineMessageModel.fromJson(json);
}

class QuoteMsg {
  String? quoteSubContent;
  int? quoteSubId;
  String? quoteSubImg;
  int? quoteSubImgType;
  int? quoteSubLinkType;
  int? quoteSubType;

  QuoteMsg({
    this.quoteSubContent,
    this.quoteSubId,
    this.quoteSubImg,
    this.quoteSubImgType,
    this.quoteSubLinkType,
    this.quoteSubType,
  });

  Map<dynamic, dynamic> toJson() {
    return <dynamic, dynamic>{}
      ..put('quoteSubContent', quoteSubContent)
      ..put('quoteSubId', quoteSubId)
      ..put('quoteSubImg', quoteSubImg)
      ..put('quoteSubImgType', quoteSubImgType)
      ..put('quoteSubLinkType', quoteSubLinkType)
      ..put('quoteSubType', quoteSubType);
  }

  QuoteMsg.fromJson(Map<dynamic, dynamic> json) {
    quoteSubContent = json.asString('quoteSubContent');
    quoteSubId = json.asInt('quoteSubId');
    quoteSubImg = json.asString('quoteSubImg');
    quoteSubImgType = json.asInt('quoteSubImgType');
    quoteSubLinkType = json.asInt('quoteSubLinkType');
    quoteSubType = json.asInt('quoteSubType');
  }
}
